package cn.gene.timeyan.security.sso.pojo.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;


/**
 * 用户详情*
 *
 * @author LWG
 * @date 2022/7/22 15:41
 * @since 1.0.0@gene.cn
 */
@Data
public class UserUserDetails implements Serializable, UserDetails {
    private Long id;
    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 情侣ID
     */
    private Long loversId;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 性别(0未知,1女,2男)
     */
    private String gender;

    /**
     * 生日
     */
    private Date birthday;

    /**
     * 地址
     */
    private String address;

    /**
     * 职业
     */
    private String profession;

    /**
     * 学校
     */
    private String school;

    /**
     * 喜好
     */
    private String hobby;

    /**
     * 个人简介
     */
    private String introduction;

    /**
     * 活跃等级
     */
    private String level;

    /**
     * 积分
     */
    private Integer score;

    /**
     * 用户贡献
     */
    private Integer contribution;

    /**
     * 用户信用点（满值100业务限制
     */
    private Integer credit;

    /**
     * 头像地址
     */
    private String avatar;

    /**
     * 背景地址
     */
    private String background;

    /**
     * 二维码
     */
    private String qrCode;

    /**
     * 经验总量
     */
    private Integer totalExperience;

    /**
     * 经验差值
     */
    private Integer dValue;


    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
    private List<UserAutority> authorities;

    public UserUserDetails() {
        authorities =new ArrayList<>();
        UserAutority authority=new UserAutority();
        authority.setAuthority("ROLE_user");
        authorities.add(authority);
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
